package com.ark.frigate.spring.publisher;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;

/**
 * @Author ZengWeiLong
 * @Description Copy Right Beyonca
 * @Date 2022/3/25 17:50
 * @Version 1.0
 */
public class BusinessEventPublisher implements ApplicationContextAware {

    private static ApplicationContext context;

    public static ApplicationContext getContext() {
        return context;
    }

    public static void publishEvent(ApplicationEvent event) {
        context.publishEvent(event);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        BusinessEventPublisher.context = applicationContext;
    }

}
